/**
 * 公共请求方法
 * 
 */

import base from './base'
import axios from 'axios'
import '../plug_in/element'


axios.defaults.timeout = 5000;  
axios.defaults.headers={
    'Content-Type':'application/json'
}
/**
 * 请求之前需要做的操作
 */
axios.interceptors.request.use(config => {
    let token = localStorage.getItem('MODEL_ID') || ''
    //将token赋值给请求头
    config.headers.token = token
    return config
}, err => {
    console.log(err);
})

const api = {
    userLogin(inteface, data){
        return axios.post(base.host + inteface, data)
    },
    registerUser(inteface, data){
        return axios.post(base.host + inteface, data)
    },
    aboutTest(inteface){
        return axios.get(base.host + inteface)
    },
    queryAllImg(inteface){
        return axios.get(base.host + inteface)
    },
    testFun(inteface, data){
        return axios.post(base.host + inteface, data)
    },
    
}

export default api;